package gui.image;

import util.Util;

import javax.swing.*;
import java.awt.image.BufferedImage;
import java.awt.*;

public class ImageComponent extends JComponent {

    private final BufferedImage buf;
    private final int imageID;

    public ImageComponent(int[] a, int width, int height, int imageID) {
        this.buf = Util.getBufferedImage(a, width, height);
        this.imageID = imageID;
        Dimension d = new Dimension(width, height);
        setSize(d);
        setMaximumSize(d);
        setMinimumSize(d);
        setPreferredSize(d);
    }

    public int getID() {
        return imageID;
    }

    public void paint(Graphics g) {
        super.paint(g);
        g.drawImage(buf, 0, 0, null);
    }
}
